extends layout

block headContent
	title Projected Blocks

block content
	+pageTitle("Projected Blocks")

	if (projectedBlocks)
		+contentSection
			
			.table-responsive
				table.table.table-borderless.table-striped.mb-0
					thead
						tr
							//th
							th

							th.text-end Height

							th.text-end
								span.border-dotted(title="UTC timestamp of the block.", data-bs-toggle="tooltip") Time

							th.text-end
								span.border-dotted(title="The number of transactions included in each block.", data-bs-toggle="tooltip") N(tx)

							th.text-end
								span.border-dotted(title="The average fee (sat/vB) for all block transactions.", data-bs-toggle="tooltip") Avg Fee
							
							th.text-end Σ Fees
							
							th.text-end % Full

					tbody

						each block, blockIndex in projectedBlocks

							tr
								td
									small.text-muted #{(blockIndex + 1).toLocaleString()}

								td.text-end
									| +#{(blockIndex + 1)}

								td.text-end
									| ~#{new Decimal(10 * (blockIndex + 1)).toDP(0)}m
								

								//- var timeAgoTime = moment.utc(new Date()).diff(moment.utc(new Date(parseInt(block.time) * 1000)));
								//- var timeAgo = moment.duration(timeAgoTime);

								//- var timeDiff = null;
								
								
								td.text-end #{(block.txCount || 0).toLocaleString()}

								td.text-end
									| #{block.avgFeeRate}
									

								td.text-end
									if (block.totalFees)
										- var currencyValue = new Decimal(block.totalFees);
										- var currencyValueDecimals = 3;

										if (userSettings.displayCurrency == "btc")
											+valueDisplaySpecial(block.totalFees, 4)

										else
											+valueDisplay(block.totalFees)


									
								
								td.text-end
									- var full = new Decimal(block.weight).dividedBy(coinConfig.maxBlockWeight).times(100);
									- var full2 = full.toDP(0);

									
									if (full >= 99 || full2 == 99)
										span.text-success 99+

									else
										span.text-primary #{full2}






			if (true)
				pre
					code.json #{JSON.stringify(topTxs, null, 4)}
			if (false)
				each block, blockIndex in projectedBlocks
					pre
						code.json #{JSON.stringify(block)}

					hr

	else
		p No blocks found
